home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
os2
/
adaptor.zip
/
ADAPT.ZIP
/
adaptor
/
examples
/
bsp2
/
life.f
< prev
next >
Wrap
Text File
|
1993-06-28
|
938b
|
43 lines
PROGRAM LIFE
c
c Simulation of a two dimensional cellular automata
C
INTEGER N,I,J,ZAHL
PARAMETER (N=256)
INTEGER FELD(N,N), FELD2(N,N),NEIGHBOR(N,N)
LOGICAL MASK(N,N)
feld = 0
!HPF$ INDEPENDENT, LOCAL_ACCESS
do j=2,n-1
do i=2,n-1
if (i .gt. j) feld(i,j) = 1
end do
end do
mask = .false.
mask (2:n-1,2:n-1) = .true.
feld2 = feld
DO 100 I=1,100
NEIGHBOR = CSHIFT(FELD,1,1)+CSHIFT(FELD,1,-1)+
> CSHIFT(FELD,2,1)+CSHIFT(FELD,2,-1)
WHERE (MASK.AND.(NEIGHBOR.GE.2).AND.(FELD.EQ.0))
FELD2 = 1
ENDWHERE
WHERE (MASK.AND.(NEIGHBOR.GE.3).AND.(FELD.EQ.1))
FELD2 = 0
ENDWHERE
FELD = FELD2
ZAHL = SUM(FELD)
PRINT *,ZAHL, ' animals in iteration ', I
100 CONTINUE
ZAHL = SUM(FELD)
PRINT *,ZAHL
END